﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Interactivity;
using Fluffy.Library.Utils;

namespace Fluffy.Library.Behaviors
{
	public class MaximizeButtonBehavior : Behavior<Button>
    {
        protected override void OnAttached()
        {
            base.OnAttached();

            AssociatedObject.Click += OnCloseButtonClick;
        }

        private void OnCloseButtonClick(object sender, RoutedEventArgs e)
        {
            Window window = UiUtils.GetParent<Window>(AssociatedObject);

            if (window == null)
                return;

	        if (window.WindowState != WindowState.Maximized)
	        {
		        window.WindowState = WindowState.Maximized;
	        }
	        else
	        {
				window.WindowState = WindowState.Normal;
	        }
        }
    }
}
